package test.top2.com.atguigu.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * ClassName: ThreadPoolUtil
 * Package: test.top2.com.atguigu.utils
 * Description:
 *
 * @Author ChenJun(有志男青年)
 * @Create 2023/5/11 16:06
 * @Version 1.0
 */
public class ThreadPoolUtil {

    private  static  ThreadPoolExecutor threadPoolExecutor;

    private ThreadPoolUtil() {
    }

    public static ThreadPoolExecutor getThreadPoolExecutor(){

        if (threadPoolExecutor == null){
            synchronized (ThreadPoolExecutor.class){
                if (threadPoolExecutor == null){
                    threadPoolExecutor= new ThreadPoolExecutor(4,
                            20,
                            5, TimeUnit.MINUTES,
                            new LinkedBlockingQueue<>());
                }

            }
        }

      return threadPoolExecutor;
    }

}
